CREATE PROC proc_addDept
@DptName  NVARCHAR(10),
@DptPhoto NVARCHAR(50),
@DptMemo  NVARCHAR(100)
AS
DECLARE @COUNT int

SELECT @COUNT = COUNT(*) FROM tab_Department  WHERE DptName = @DptName

IF(@COUNT = 1)
  RETURN 1
ELSE if(len(@DptName)=0) 
 RETURN 2
else
begin
  INSERT INTO tab_Department(DptName,DptPhoto,DptMemo) values (@DptName,@DptPhoto,@DptMemo)
  RETURN 0
end
GO




CREATE PROC proc_delDept
@DptName  NVARCHAR(10)
AS
DECLARE @COUNT int

SELECT @COUNT = COUNT(*) FROM tab_Department  WHERE DptName = @DptName

IF(@COUNT = 1)
BEGIN
DELETE tab_Department WHERE DptName = @DptName
RETURN 0
END
ELSE  
RETURN 1

GO



CREATE PROC proc_upDateDept
@DptName  NVARCHAR(10),
@DptPhoto NVArchar(50),
@DptMemo NVarchar(100)
AS
update tab_Department set dptPhoto = @dptPhoto, dptMemo = @dptMemo where DptName=@DptName
return 0
GO



CREATE PROC proc_getCompanyInfo
AS
SELECT * FROM tab_Company
GO


CREATE PROC proc_upDateCompany
@CompanyName  NVARCHAR(30),
@CompanyMemo NVarchar(500)
AS
update tab_Company set CompanyMemo = @CompanyMemo ,CompanyName=@CompanyName
return 0
GO

